 <?php 
include('init.php');
if ( ! $search_query) {
    $search_query = htmlescape(trim($_GET['q']));
}
$nodes = new Nodes();
$results = $nodes->nodeChilds($nodes->search($search_query));
?>
<div id="content">
<?php require('templates/create_node_link.php'); ?>
<?php
if ( is_array($results) && count($results) ) {
    foreach($results as $node) { 
?>
        <div class="node">
            <h3><?php $node->renderLink(); ?></h3>
            <div class="extradata">
            	<?php
				foreach( $nodes->nodeChilds($nodes->getLinksFrom($node->getId())) as $link ) {
					echo '<span class="to">';
					$link->renderLink();
					echo '</span>';
				}
				?>
            </div>
            <div>
                <?php echo substr($node->getContent(),0,350); ?>...
            </div>
        </div>
<?php
    }
} else {
?>
    <span>No se encontro nada, prueba una diferente búsqueda o <a href="<?php echo DOMAIN.'/post.php?q='.urlescape($search_query); ?>" >crea el nodo</a>.</span>
<?php
}
?>
</div>
<?php
$options = array(
    'title' => $search_query.' - Node'
);
display($options);
